#include"ros/ros.h"
#include<std_msgs/String.h>
/*
    发布实现：
        1.包含头文件
            #include<std_msgs/String.h>
        2.初始化ros节点
        3.创建句柄
        4.创建发布者
        5.编写发布逻辑并发布数据
        6.spin()

*/

void doMsg(const std_msgs::String::ConstPtr& msg){
    //通过msg获取操作并订阅
    ROS_INFO("翠花订阅的数据:%s",msg->data.c_str());

}
int main(int argc, char *argv[])
{
    setlocale(LC_ALL,"");
    ros::init(argc,argv,"erCuihua");

    ros::NodeHandle nh;

    ros::Subscriber sub = nh.subscribe("fang",10,doMsg);

    ros::spin();



    return 0;
}
 